<?php
namespace Admin\Model;
use Think\Model\RelationModel;

    class AdminUserModel extends RelationModel
    {

        protected $_link = array(
            'actor'=>array(
                'mapping_type'=>self::MANY_TO_MANY,
                'relation_table'=>'hx_user_actor',
                'foreign_key'=> 'user_id',
                'relation_foreign_key'=> 'actor_id',
                'mapping_fields'=>'aname',
                'as_fields'=>'aname',
            ),
        );


        //自动验证
        protected $_validate = array(
            array('name','require','用户名不能为空'),
            array('pwd','require','密码不能为空'),
            array('phone','require','手机号不能为空'),
            array('name','','用户名已存在',0, 'unique'),
            array('name','/^[a-zA-Z]\w{5,11}$/','用户名必须以字母开头,长度为6-12位!', 0, 'regex'),
            array('pwd','/\w{6,18}/','密码长度必须为6-18位!'),
            array('phone','/^1[^0129]\d{9}$/','不能填写非法手机号', 0, 'regex'),
        );

        //自动完成
        protected $_auto = array (
            array('pwd','md5',3,'function'),
        );
    }
